<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/layui/layui_2/layui/css/layui.css" media="all"/>
</head>
<body>

<!-- 修改员工 -->
<div id="add_emp_div">
    <div>
        <form id="add_emp_form" class="layui-form" action="" method="post" lay-filter="add_emp_form">
        	<div class="layui-form-item" style="font-size: 18px;background: #5FB878;">
	  			<label class="layui-form-label">修改员工</label>
	  		</div>
            <div style="width: 400px;height:500px;float: left">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">真实姓名:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="phone" lay-verify="required" placeholder="请输入..."
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">登录名称:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="phone" lay-verify="required" placeholder="请输入..."
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">登录密码:</label>
                        <div class="layui-input-inline">
                            <input type="password" name="phone" lay-verify="required" placeholder="请输入..."
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所在部门:</label>
                    <div class="layui-input-inline">
                        <select name="dept.id" lay-filter="aihao">
                            <option value="0">人事部</option>
                            <option value="1">阅读</option>
                            <option value="2">游戏</option>
                            <option value="3">音乐</option>
                            <option value="4">旅行</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="sex" value="男" title="男" checked="">
                        <input type="radio" name="sex" value="女" title="女">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">员工头像:</label>
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="upload_btn">上传图片</button>
                    </div>
                    <%--  <input type="file" name="img" id="upload_btn_1"/>--%>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label">员工备注：</label>
                    <div class="layui-input-block">
                        <textarea name="remark" value="" required placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">员工级别:</label>
                    <div class="layui-input-inline">
                        <select name="dept.id" lay-filter="aihao">
                            <option value="0" selected="">普工</option>
                            <option value="1">部门经理</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">权限级别:</label>
                    <div class="layui-input-inline">
                        <select name="dept.id" lay-filter="aihao">
                            <option value="0" selected="">普通操作者</option>
                            <option value="1">部门经理</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">新增员工</button>
                    </div>
                </div>
            </div>

            <!--右边上传图片预览-->
            <div style="width:auto; float: left">
                <img src="${pageContext.request.contextPath}/images/face.jpg" style="width: 150px;height: 150px"
                     class="layui-upload-img layui-circle" id="upload_img"/>
                <p id="upload_imgText"></p>
            </div>


        </form>
    </div>
</div>
<script src="${pageContext.request.contextPath }/layui/layui_2/layui/layui.js"></script>
<script>
    layui.use(['element', 'table', 'jquery', 'layer', 'form', 'upload'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form,
            upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#upload_btn'
            , url: '/upload/'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload_img').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#upload_imgText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }

        });


        //监听提交
        form.on('submit(add_emp_form)', function (data) {
            layer.alert(JSON.stringify(data), {
                title: '最终的提交信息'
            })
            return false;
        });


    });

</script>

</body>
</html>
